package logic

import (
	"context"
	"net/http"
	"vip_srv/vip_srv"

	"api/internal/svc"
	"github.com/zeromicro/go-zero/core/logx"
)

type OrderRetLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewOrderRetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderRetLogic {
	return &OrderRetLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *OrderRetLogic) OrderRet(req *http.Request) (string, error) {
	// todo: add your logic here and delete this line
	req.ParseForm()
	out_trade_no := req.PostForm.Get("out_trade_no")
	trade_status := req.PostForm.Get("trade_status")
	_, err := l.svcCtx.VipSrv.OrderRet(l.ctx,&vip_srv.OrderRetRequest{
		OutTradeNo:  out_trade_no,
		TradeStatus: trade_status,
	})
	if err != nil {
		return "", err
	}
	return "success", nil
}
